package com.wyiot.pet.controller;

import com.wyiot.core.api.ValidateGroup;
import com.wyiot.pet.model.dto.LogisticsInfoDTO;
import com.wyiot.pet.model.dto.OrderDTO;
import com.wyiot.pet.model.dto.WayBillDTO;
import com.wyiot.pet.service.*;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 工作人员管理控制层
 *
 * @author yly
 * @since 2022年04月06日
 */
@RestController
public class WorkerController {
    @Resource
    WorkerService workerService;
    /**
     * 为运单绑定运输箱
     *
     * @see WayBillDTO
     */
    @PutMapping("/waybill/box")
    public void bindingBox(@RequestBody @Validated WayBillDTO wayBillDTO, BindingResult result) {

        workerService.bindingBox(wayBillDTO);
    }

    /**
     * 快递小哥上门取件
     *
     * @see OrderDTO
     */
    @PutMapping("/worker/orderstate")
    public void workerToDoorTake(@RequestBody @Validated({ValidateGroup.Third.class}) OrderDTO orderDTO, BindingResult result) {

        workerService.isTakeCodeTrue(orderDTO);
    }

    /**
     * 填写物流信息
     *
     * @see LogisticsInfoDTO
     */
    @PutMapping("/worker/logisticsinfo")
    public void logisticsInfo(@RequestBody @Validated LogisticsInfoDTO logisticsInfoDTO, BindingResult result) {
        workerService.fillLogisticsInfo(logisticsInfoDTO);
    }
}
